package com.ruoyi.web.controller.tool;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.FaApsDevice;
import com.ruoyi.system.domain.FaEsmOrderinfo;
import com.ruoyi.system.mapper.FaApsDeviceMapper;
import com.ruoyi.system.mapper.FaEsmOrderinfoMapper;
import com.ruoyi.system.service.IFaEsmOrderinfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api("ESM")
@RestController
@RequestMapping("/esm")
public class EsmController extends BaseController
{
    private static int a1 = 0;
    private int a2 = 0;

    @ApiOperation("获取产线列表test")
    @GetMapping("/devicelisttest")
    //http://localhost:8090/esm/devicelisttest
    public AjaxResult devicelisttest()
    {
        a1++;
        a2++;
        return error("a1=" + a1 + " a2=" + a2);
    }


    @Autowired
    private IFaEsmOrderinfoService faEsmOrderinfoService;

    @ApiOperation("获取订单列表")
    @GetMapping("/orderlist")
    //http://localhost:8090/esm/orderlist?sn=1312&po=223w
    //http://localhost:8090/esm/orderlist?po=223w
    public TableDataInfo orderlist(FaEsmOrderinfo faEsmOrderinfo)
    {
        List<FaEsmOrderinfo> list = faEsmOrderinfoService.selectFaEsmOrderinfoList(faEsmOrderinfo);
        return getDataTable(list);
    }

    @Autowired
    private FaApsDeviceMapper faApsDeviceMapper;

    @ApiOperation("获取设备列表")
    @GetMapping("/devicelist")
    //http://localhost:8090/esm/devicelist?name=dasdv
    //http://localhost:8089/dev-api/system/device/list?pageNum=2&pageSize=10
    public AjaxResult devicelist(FaApsDevice faApsDevice) {
//        FaApsDevice a = faApsDeviceMapper.selectFaApsDeviceByDeviceId(2);
//        return AjaxResult.success(a);
        List<FaApsDevice> list = faApsDeviceMapper.selectFaApsDeviceList(faApsDevice);
        return AjaxResult.success(list);
    }

    @ApiOperation("获取设备列表2")
    @GetMapping("/devicelist2")
    //http://localhost:8090/esm/devicelist2?pageNum=2&pageSize=5&name=faf11
    //, Integer pageNum(1,2,3...), Integer pageSize(1,2...)
    public TableDataInfo devicelist2(FaApsDevice faApsDevice) {
        startPage();
        List<FaApsDevice> list = faApsDeviceMapper.selectFaApsDeviceList(faApsDevice);
        return getDataTable(list);
    }

}


